<template>
	<view class="page_content root-safe-area">
		<template v-if="rows.length > 0">
			<view class="content_card" v-for="(item,index) in rows" :key="index" :data-row="item" @click.stop="onTap">
				<view class="">
					{{item.itemName}}
				</view>
				<view class="digit-row">
					<view class="digit-row-item">
						<text class="digit-row-item-error">{{item.unDisposeNum}}</text>
						<text class="digit-row-item-key">未处置警告</text>
					</view>
					<view class="digit-row-item">
						<text class="digit-row-item-ok">{{item.disposeNum}}</text>
						<text class="digit-row-item-key">已处置警告</text>
					</view>
				</view>
				
				<view class="row-item">
					<image src="/static/home/location.png" mode="aspectFit" style="width: 26rpx;height: 28rpx;margin-right: 8rpx;"></image>
					<text class="startDateView-text" style="margin-top: -4rpx;">{{item.location}}</text>
				</view>
				<view class="row-item">
					<image src="/static/home/cala.png" mode="aspectFit" style="width: 26rpx;height: 28rpx;margin-right: 8rpx;"></image>
					<text class="startDateView-text" style="margin-top: -4rpx;">{{dateStr(item)}}</text>
				</view>
				<view class="row-item">
					<image src="/static/home/user.png" mode="aspectFit" style="width: 26rpx;height: 28rpx;margin-right: 8rpx;"></image>
					<text class="startDateView-text" style="margin-top: -4rpx;">{{managerStr(item)}}</text>
				</view>
			</view>
		</template>
		<template v-else>
			<view class="nodata">
				<view class="img"></view>
				<view class="text">暂无数据</view>
			</view>
		</template>
	</view>
</template>

<script>
	import moment from "moment";
	export default {
		data() {
			return {
				rows:[
					// {
					//       "disposeNum": 10,
					//       "itemId": 1,
					//       "itemName": "项目A",
					//       "location": "北京",
					//       "projectDate": "2022-01-01",
					//       "projectManager": "张三",
					//       "projectManagerTel": "12345678901",
					//       "unDisposeNum": 5
					// },
					// {
					//       "disposeNum": 10,
					//       "itemId": 1,
					//       "itemName": "项目A",
					//       "location": "北京",
					//       "projectDate": "2022-01-01",
					//       "projectManager": "张三",
					//       "projectManagerTel": "12345678901",
					//       "unDisposeNum": 5
					// },
					// {
					//       "disposeNum": 10,
					//       "itemId": 1,
					//       "itemName": "项目A",
					//       "location": "北京",
					//       "projectDate": "2022-01-01",
					//       "projectManager": "张三",
					//       "projectManagerTel": "12345678901",
					//       "unDisposeNum": 5
					// }
				]
			}
		},
		computed:{
			
		},
		onShow() {
			this.$weixinAuth.isNeedRegister().then(ok=>{
				if(ok.needRegister) {
					this.$Router.push('/pages/register/register')
				} else {
					this.loadData()
				}
			})
		},
		methods: {
			loadData(){
				let self = this;
				self.$progressHud.showLoading();
				self.$NetApi.getMethod('/loyu-api/app/alarm/info/list').then(ok => {
					self.$progressHud.hideLoading();
					self.rows = ok.rows;
				}, fail => {
					self.$progressHud.hideLoading();
					self.$progressHud.showToast(fail.errMsg || '网络错误');
				})
			},
			onTap(e){
				let row = e.currentTarget.dataset.row;
				this.$Router.push({
					path:'/modules/warnings/pages/warningDetail/warningDetail',
					query:{
						id:row.itemId || ''
					}
				})
			},
			managerStr(item){
				return '项目经理：' + item.projectManager + '（' + item.projectManagerTel + '）';
			},
			dateStr(item){
				let str = moment(item.projectDate).format('YYYY年MM月DD日 投产');
				return str;
			}
		}
	}
</script>

<style lang="scss" scoped>
	.page_content{
		width: 100%;
		min-height: 100%;
		font-family: Roboto;
		color: #000000;
	}
	.content_card{
		margin-left: 32rpx;
		margin-right: 32rpx;
		margin-top: 32rpx;
		
		width: calc(100% - 64rpx);

		display: flex;
		flex-direction: column;
		padding: 32rpx;
		gap: 0px 20rpx;
		flex-wrap: wrap;
		align-content: flex-start;
		
		border-radius: 24rpx;
		background: linear-gradient(0deg, rgba(0, 0, 0, 0.001), rgba(0, 0, 0, 0.001)), #FFFFFF;
		box-shadow: 0px 2rpx 4rpx 0px rgba(0, 0, 0, 0.05);
	}
	.row-item{
		display: flex;
		flex-direction: row;
		align-items: center;
		column-gap: 16rpx;
		color: #4B5563;
		margin-top: 16rpx;
		
		font-size: 28rpx;
		font-weight: normal;
		line-height: 40rpx;
	}
	.digit-row{
		display: flex;
		flex-direction: row;
		align-items: flex-start;
		justify-content: flex-start;
		width: 100%;
		height: 152rpx;
		gap: 24rpx;
	}
	.digit-row-item{
		display: flex;
		flex-direction: column;
		flex: 1 1 calc(50% - 12rpx);
		background-color: #F9FAFB;
		height: 100%;
		justify-content: center;
		row-gap: 8rpx;
		padding-left: 24rpx;
		border-radius: 8rpx;
	}
	.digit-row-item-error{
		color: $power-color-error;
	}
	.digit-row-item-ok{
		color: $power-color-ok;
	}
	.digit-row-item-key{
		font-size: 28rpx;
		font-weight: normal;
		line-height: 40rpx;
		letter-spacing: normal;
		color: #4B5563;
	}
	
	.nodata {
		margin-top: 40%;
		width: 100%;
		height: 100%;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		background-color: transparent;
		// padding-bottom: 25%;
	}
	
	.nodata .img {
		width: 50vw;
		height: 41vw;
		margin-bottom: 10rpx;
		background: url(/static/mine/no_data.png) no-repeat center center;
		background-size: 100% auto;
	}
	
	.nodata .text {
		font-size: 30rpx;
		color: #999;
	}

</style>
